package com.bookstore.bauhinia.controller;

import com.bookstore.bauhinia.pojo.Book;
import com.bookstore.bauhinia.pojo.CommonResult;
import com.bookstore.bauhinia.service.BookFeignService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class BookConsumerController {
    @Resource
    private BookFeignService bookFeignService;

    @PostMapping("/book/insert")
    public CommonResult insertBook(Book record) {
        return bookFeignService.insertBook(record);
    }

    @GetMapping("/book/get/{id}")
    public CommonResult getBookById(@PathVariable("id") int id) {
        return bookFeignService.getBookById(id);
    }

    @GetMapping("/book/delete/{id}")
    public CommonResult deleteBookById(@PathVariable("id") int id) {
        return deleteBookById(id);
    }

    @PostMapping("/book/update")
    public CommonResult updateBook(Book record) {
        return bookFeignService.updateBook(record);
    }
}
